<template>
  <van-row class="panel-rectify-operate">
    <van-cell-group title="发布整改任务">
      <!--
      <van-field required label-width="100px" label="责任部门" input-align="right" readonly placeholder="请指定整改责任部门" v-model="dept" @click="showPageDeptList=true"/>
      <van-row class="split-h"/>-->
      <card-receivers :parentPath="dutyDept" :showChildren="1" v-model="receivers"/>
      <!-- <van-row class='operate-area' gutter="5">
        <van-button type="info" @click="submit">确定</van-button>
      </van-row>
      <van-row class='operate-area' gutter="5">
        <van-button type="warning" @click="deletsubmit">删除此问题</van-button>
      </van-row> -->
    <van-row class='operate-area' gutter="10">
      <van-radio-group v-model="checkResult" direction="horizontal">
        <van-col span="12">
          <van-button type="info" @click="submit">确定</van-button>
        </van-col>
        <van-col span="12">
          <van-button type="danger" @click="deletsubmit">删除此问题</van-button>
        </van-col>
      </van-radio-group>
    </van-row>
    </van-cell-group>
    <van-popup
      v-model="showPageDeptList"
      position="right"
      get-container="body"
      style="width: 100%; height: 100%; background-color: #F9F9F9">
      <page-dept-list v-if="showPageDeptList" @onCancel="showPageDeptList = false" @onConfirm="endSelectDept"/>
    </van-popup>
  </van-row>
</template>

<script>
import ApiMixin from '@/mixins/ApiMixin'
import PageDeptList from '@/views/rectify/common/page/PageDeptList'
import CardReceivers from '@/views/common/card/CardReceivers'
export default {
  name: 'PanelRectifyInit',
  mixins: [ApiMixin],
  components: { PageDeptList,CardReceivers },
  data () {
    return {
      checkResult:'',
      showPageDeptList: false,
      dutyDept: this.rectify.dutyDept,
      formData: this.$vo.createRectifyFormData(),
      receivers: []
    }
  },
  methods: {
    endSelectDept (value) {
      this.dutyDept = value
      this.showPageDeptList = false
    },
    submit () {
      /*
      if (this.dutyDept.trim() === '') {
        this.$dialog.alert({
          message: '请选择整改责任部门'
        })
        return
      } */
      if (this.receivers.length === 0) {
        this.$dialog.alert({
          message: '请选择接收人员'
        })
        return
      }
      this.formData.op = this.$vo.RectStatus.TASK
      this.formData.receivers = this.receivers
      // this.rectify.duty_dept = this.dutyDept
      // 提交
      this.doUpdateRectify()
      
    },
    //删除此条问题数据
    deletsubmit(){
       this.formData.op = 'delete'
       this.doUpdateRectify()
    }
  },
  computed: {
    dept: function () {
      return this.dutyDept.substr(this.dutyDept.indexOf('/') + 1)
    }
  }
}
</script>

<style scoped lang="less">
</style>
